//
//  SelectTribeViewController.m
//  PigMarket
//
//  Created by mac on 2019/3/28.
//  Copyright © 2019 felix.pigmarket.oc. All rights reserved.
//

#import "SelectTribeViewController.h"
#import "AreaDropDownListView.h"
#import "VarietyListViewController.h"

#define AreaGrayColor [UIColor colorWithHexString:@"#666666"]
@interface SelectTribeViewController ()
/**
 顶部提示bg
 */
@property (nonatomic , strong) UIView *topTipsBgView;
/**
 顶部提示
 */
@property (nonatomic , strong)  YYLabel *topTipsLab;
/**
 选择小猪部落title
 */
@property (nonatomic , strong) UILabel *selecttribeTitleLab;
/**
 选择省份
 */
@property (nonatomic , strong) UILabel *provinceLab;
/**
 城市
 */
@property (nonatomic , strong) UILabel *cityLab;
/**
 区县
 */
@property (nonatomic , strong) UILabel *districtLab;
/**
 部落
 */
@property (nonatomic , strong) UILabel *tribeLab;
/**
 默认省份Lab
 */
@property (nonatomic , strong) UILabel *defaultProvinceLab;
/**
 省份Btn
 */
@property (nonatomic , strong) UIButton *selectProvinceBtn;
/**
 默认城市Lab
 */
@property (nonatomic , strong) UILabel *defaultCityLab;
/**
 城市Btn
 */
@property (nonatomic , strong) UIButton *selectCityBtn;
/**
 默认区县Lab
 */
@property (nonatomic , strong) UILabel *defaultDistrictLab;
/**
 区县Btn
 */
@property (nonatomic , strong) UIButton *selectDistrictBtn;
/**
 默认部落Lab
 */
@property (nonatomic , strong) UILabel *defaulTribeLab;
/**
 部落Btn
 */
@property (nonatomic , strong) UIButton *selecttribeBtn;
/**
 provinceLine
 */
@property (nonatomic , strong) UIView *provinceLine;
/**
 cityLine
 */
@property (nonatomic , strong) UIView *cityLine;
/**
 districtLine
 */
@property (nonatomic , strong) UIView *districtLine;
/**
 tribeLine
 */
@property (nonatomic , strong) UIView *tribeLine;
/**
 底部提示
 */
@property (nonatomic , strong) UILabel *bottomTips;
/**
 确定Btn
 */
@property (nonatomic , strong) UIButton *confirmBtn;
/**
 省份arr
 */
@property (nonatomic , strong) NSMutableArray *provinceArr;
/**
 cityArr
 */
@property (nonatomic , strong) NSMutableArray *cityArr;
/**
 districtArr
 */
@property (nonatomic , strong) NSMutableArray *districtArr;
/**
 tribeArr
 */
@property (nonatomic , strong) NSMutableArray *tribeArr;
/**
 selectProvienceId
 */
@property (nonatomic , strong) NSNumber *selectProvienceId;
/**
 selectCityId
 */
@property (nonatomic , strong) NSNumber *selectCityId;
/**
 selectDistrictId
 */
@property (nonatomic , strong) NSNumber *selectDistrictId;
/**
 selectTribeId
 */
@property (nonatomic , strong) NSNumber *selectTribeId;
/**
 areaDropDownView
 */
@property (nonatomic , strong) AreaDropDownListView *areaDropDownView;
@end

@implementation SelectTribeViewController

#pragma mark - view life cycle
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"选择部落";
    self.view.backgroundColor = [UIColor whiteColor];
    [self setUpView];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
}

- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
}
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self.areaDropDownView hide];
}

#pragma mark - init method
- (void)setUpView {
    [self initView];
    [self initLayout];
    [self initAction];
    [self initData];
}
- (void)initView {
    [self.view addSubview:self.topTipsBgView];
    [self.topTipsBgView addSubview:self.topTipsLab];
    [self.view addSubview:self.selecttribeTitleLab];
    [self.view addSubview:self.provinceLab];
    [self.view addSubview:self.defaultProvinceLab];
    [self.view addSubview:self.selectProvinceBtn];
    [self.view addSubview:self.provinceLine];
    [self.view addSubview:self.cityLab];
    [self.view addSubview:self.defaultCityLab];
    [self.view addSubview:self.selectCityBtn];
    [self.view addSubview:self.cityLine];
    [self.view addSubview:self.districtLab];
    [self.view addSubview:self.defaultDistrictLab];
    [self.view addSubview:self.selectDistrictBtn];
    [self.view addSubview:self.districtLine];
    [self.view addSubview:self.tribeLab];
    [self.view addSubview:self.defaulTribeLab];
    [self.view addSubview:self.selecttribeBtn];
    [self.view addSubview:self.tribeLine];
    [self.view addSubview:self.confirmBtn];
    [self.view addSubview:self.bottomTips];
}

- (void) initLayout {
    [self.topTipsBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.mas_equalTo(0);
        make.height.mas_equalTo(58);
    }];
    [self.topTipsLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(UIEdgeInsetsMake(6, 20, 6, 20));
    }];
    [self.selecttribeTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.topTipsBgView.mas_bottom).offset(15);
        make.left.mas_equalTo(20);
        make.height.mas_equalTo(20);
        
    }];
    [self.provinceLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.top.mas_equalTo(self.selecttribeTitleLab.mas_bottom).offset(30);
        make.height.mas_equalTo(18);
    }];
    [self.defaultProvinceLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.provinceLab.mas_bottom).offset(5);
        make.left.mas_equalTo(20);
        make.height.mas_equalTo(18);
    }];
    [self.selectProvinceBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.defaultProvinceLab.mas_centerY);
        make.right.mas_equalTo(-30);
        make.height.mas_equalTo(28);
        make.width.mas_equalTo(200);
    }];
    [self.provinceLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.top.mas_equalTo(self.defaultProvinceLab.mas_bottom).offset(10);
        make.right.mas_equalTo(-30);
        make.height.mas_equalTo(1);
    }];
    [self.cityLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.top.mas_equalTo(self.provinceLine.mas_bottom).offset(10);
        make.height.mas_equalTo(18);
    }];
    [self.defaultCityLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.cityLab.mas_bottom).offset(5);
        make.left.mas_equalTo(20);
        make.height.mas_equalTo(18);
    }];
    [self.selectCityBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.defaultCityLab.mas_centerY);
        make.right.mas_equalTo(-30);
        make.height.mas_equalTo(28);
        make.width.mas_equalTo(200);
    }];
    [self.cityLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.top.mas_equalTo(self.defaultCityLab.mas_bottom).offset(10);
        make.right.mas_equalTo(-30);
        make.height.mas_equalTo(1);
    }];
    [self.districtLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.top.mas_equalTo(self.cityLine.mas_bottom).offset(10);
        make.height.mas_equalTo(18);
    }];
    [self.defaultDistrictLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.districtLab.mas_bottom).offset(5);
        make.left.mas_equalTo(20);
        make.height.mas_equalTo(18);
    }];
    [self.selectDistrictBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.defaultDistrictLab.mas_centerY);
        make.right.mas_equalTo(-30);
        make.height.mas_equalTo(28);
        make.width.mas_equalTo(200);
    }];
    [self.districtLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.top.mas_equalTo(self.defaultDistrictLab.mas_bottom).offset(10);
        make.right.mas_equalTo(-30);
        make.height.mas_equalTo(1);
    }];
    [self.tribeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.top.mas_equalTo(self.districtLine.mas_bottom).offset(10);
        make.height.mas_equalTo(18);
    }];
    [self.defaulTribeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.tribeLab.mas_bottom).offset(5);
        make.left.mas_equalTo(20);
        make.height.mas_equalTo(18);
    }];
    [self.selecttribeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.defaulTribeLab.mas_centerY);
        make.right.mas_equalTo(-30);
        make.height.mas_equalTo(28);
        make.width.mas_equalTo(200);
    }];
    [self.tribeLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.top.mas_equalTo(self.defaulTribeLab.mas_bottom).offset(10);
        make.right.mas_equalTo(-30);
        make.height.mas_equalTo(1);
    }];
    [self.confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.tribeLine.mas_bottom).offset(72);
        make.left.mas_equalTo(30);
        make.right.mas_equalTo(-30);
        make.height.mas_equalTo(48);
    }];
    [self.bottomTips mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.right.mas_equalTo(-20);
        make.bottom.mas_equalTo(self.view.mas_bottom).offset(-IPHONEXBottomEdge);
    }];
}

- (void) initAction {
    [self.selectProvinceBtn addTarget:self action:@selector(selectProvinceTapped) forControlEvents:UIControlEventTouchUpInside];
    [self.selectCityBtn addTarget:self action:@selector(selectCityTapped) forControlEvents:UIControlEventTouchUpInside];
    [self.selectDistrictBtn addTarget:self action:@selector(selectDistrictTapped) forControlEvents:UIControlEventTouchUpInside];
    [self.selecttribeBtn addTarget:self action:@selector(selecttribeTapped) forControlEvents:UIControlEventTouchUpInside];
    [self.confirmBtn addTarget:self action:@selector(confirmTapped) forControlEvents:UIControlEventTouchUpInside];
}

- (void)initData {
    NSNumber *parentId = @0;
    @weakify(self);
    [[[PigMarketApi sharedInstance] areasListWithParentId:parentId] subscribeNext:^(SelectTribesList * _Nullable areaList) {
        @strongify(self);
        [self.provinceArr addObjectsFromArray:areaList.list];
    } error:^(NSError * _Nullable error) {
        
        @strongify(self);
        [self handlingError:error];
    }];
}

#pragma mark - delegate
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    [self.areaDropDownView hide];
}
#pragma mark - target action
//选择省份
- (void)selectProvinceTapped {
    CGFloat topSpace = CGRectGetMaxY(self.provinceLine.frame) + TopBarHeight;
    [self showDropDownWithSpace:topSpace type:AreaTypeProvince areaArr:self.provinceArr];
   
}
//选择城市
- (void)selectCityTapped {
    CGFloat topSpace = CGRectGetMaxY(self.cityLine.frame) + TopBarHeight;
    
    if ([JTool iSNull:self.selectProvienceId]) {
        [self toastWithContent:@"请先选择省份"];
        return;
    }
    //请求数组之前清空数组
    [self.cityArr removeAllObjects];
    
    [[[PigMarketApi sharedInstance] areasListWithParentId:self.selectProvienceId] subscribeNext:^(SelectTribesList * _Nullable areaList) {
        [self.cityArr addObjectsFromArray:areaList.list];
        [self showDropDownWithSpace:topSpace type:AreaTypeCity areaArr:self.cityArr];
    } error:^(NSError * _Nullable error) {
        
    }];
}
//选择区县
- (void)selectDistrictTapped {
    CGFloat topSpace = CGRectGetMaxY(self.districtLine.frame) + TopBarHeight;
    if ([JTool iSNull:self.selectProvienceId]) {
        [self toastWithContent:@"请先选择省份"];
        return;
    }
    if ([JTool iSNull:self.selectCityId]) {
        [self toastWithContent:@"请先选择城市"];
        return;
    }
    //请求数组之前清空数组
    [self.districtArr removeAllObjects];
    
    [[[PigMarketApi sharedInstance] areasListWithParentId:self.selectCityId] subscribeNext:^(SelectTribesList * _Nullable areaList) {
        
        [self.districtArr addObjectsFromArray:areaList.list];
        [self showDropDownWithSpace:topSpace type:AreaTypeDistrict areaArr:self.districtArr];
    } error:^(NSError * _Nullable error) {
        
    }];
}
//选择部落
- (void)selecttribeTapped {
    CGFloat topSpace = CGRectGetMaxY(self.tribeLine.frame) + TopBarHeight;
    
    if ([JTool iSNull:self.selectProvienceId]) {
        [self toastWithContent:@"请先选择省份"];
        return;
    }
    if ([JTool iSNull:self.selectCityId]) {
        [self toastWithContent:@"请先选择城市"];
        return;
    }
    if ([JTool iSNull:self.selectDistrictId]) {
        [self toastWithContent:@"请先选择区县"];
        return;
    }
    //请求数组之前清空数组
    [self.tribeArr removeAllObjects];
    
    [[[PigMarketApi sharedInstance] tribeListWithParentId:self.selectDistrictId] subscribeNext:^(SelectTribesList * _Nullable areaList) {
        
        
        [self.tribeArr addObjectsFromArray:areaList.list];
        [self showDropDownWithSpace:topSpace type:AreaTypeTribe areaArr:self.tribeArr];
    } error:^(NSError * _Nullable error) {
        
    }];
}

//确定
- (void)confirmTapped {
    if ([JTool iSNull:self.selectTribeId]) {
        [self toastWithContent:@"请选择部落"];
        return;
    }
    //保存部落ID
    UserInfo *userInfo = [UserInfoDataProvider sharedInstance].userInfo;
    userInfo.tribeId = self.selectTribeId;
    [UserInfoDataProvider sharedInstance].userInfo = userInfo;
    
    VarietyListViewController *varietyListVC = [[VarietyListViewController alloc] init];
//    varietyListVC.tribeId = self.selectTribeId;
    varietyListVC.varietiesId = self.varietyId;
    [self.navigationController pushViewController:varietyListVC animated:YES];
}

#pragma mark - private method

- (void)showDropDownWithSpace:(CGFloat)topSpace type:(AreaType)type areaArr:(NSArray *)areaArr{
    
    [self.areaDropDownView showWithFrame:topSpace type:type areaArr:areaArr];
    
    switch (type) {//设置按钮的select的布尔值，当前选中按钮的布尔值为Yes，其余按钮设置为No，以便显示不同状态的图片
        case AreaTypeProvince:
            self.selectProvinceBtn.selected = !self.selectProvinceBtn.selected;
            self.selectCityBtn.selected = NO;
            self.selectDistrictBtn.selected = NO;
            self.selecttribeBtn.selected = NO;
            
            if (!self.selectProvinceBtn.selected) {//布尔值为NO，为收起下拉框状态
                [self.areaDropDownView hide];
            }
            break;
        case AreaTypeCity:
            self.selectCityBtn.selected = !self.selectCityBtn.selected;
            self.selectProvinceBtn.selected = NO;
            self.selectDistrictBtn.selected = NO;
            self.selecttribeBtn.selected = NO;
            if (!self.selectCityBtn.selected) {
                
                [self.areaDropDownView hide];
            }
            break;
        case AreaTypeDistrict:
            self.selectDistrictBtn.selected = !self.selectDistrictBtn.selected;
            self.selectProvinceBtn.selected = NO;
            self.selectCityBtn.selected = NO;
            self.selecttribeBtn.selected = NO;
            if (!self.selectDistrictBtn.selected) {
                
                [self.areaDropDownView hide];
            }
            break;
        case AreaTypeTribe:
            self.selecttribeBtn.selected = !self.selecttribeBtn.selected;
            self.selectProvinceBtn.selected = NO;
            self.selectCityBtn.selected = NO;
            self.selectDistrictBtn.selected = NO;
            if (!self.selecttribeBtn.selected) {
                
                [self.areaDropDownView hide];
            }
            break;
        default:
            break;
    }
    //选择地址回调
    @weakify(self);
    [self.areaDropDownView setSelectAreaBlock:^(NSString *area,NSNumber *currentSelectId ,AreaType areaType) {
        @strongify(self);
        self.selectProvinceBtn.selected = NO;
        self.selectCityBtn.selected = NO;
        self.selectDistrictBtn.selected = NO;
        self.selecttribeBtn.selected = NO;
        switch (areaType) {//省份
            case AreaTypeProvince:
                self.defaultProvinceLab.text = area;
                self.selectProvienceId = currentSelectId;
                break;
            case AreaTypeCity://城市
                self.defaultCityLab.text = area;
                self.selectCityId = currentSelectId;

                break;
            case AreaTypeDistrict://区县
                self.defaultDistrictLab.text = area;
                self.selectDistrictId = currentSelectId;
                break;
            case AreaTypeTribe://部落
            {
                self.defaulTribeLab.text = area;
                self.selectTribeId = currentSelectId;
    
                //选择完部落后，显示底部提示信息
                NSString *allAreaStr = [NSString stringWithFormat:@"%@%@%@%@",self.defaultProvinceLab.text,self.defaultCityLab.text,self.defaultDistrictLab.text,self.defaulTribeLab.text];
                self.bottomTips.text = [NSString stringWithFormat:@"当猪猪出栏时，您可以在%@销售它",allAreaStr];
            }
                break;
            default:
                break;
        }
     }];
}
#pragma mark - getter and setter
- (UIView *)topTipsBgView {
    if (!_topTipsBgView) {
        _topTipsBgView = [[UIView alloc] init];
        _topTipsBgView.backgroundColor = [UIColor colorWithHexString:@"#FFF9D4"];
    }
    return _topTipsBgView;
}
- (YYLabel *)topTipsLab {
    if (!_topTipsLab) {
        _topTipsLab = [[YYLabel alloc] init];
         _topTipsLab.numberOfLines = 0;
        NSString *tipsStr = @"温馨提示：小猪出栏后您可以在本部落或其他相邻部落销售。豚集将为您提供屠宰、分割、配送全程冷链物流服务。";

        NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:tipsStr];
        [attributedString yy_setFont:[UIFont smallFont] range:attributedString.yy_rangeOfAll];
        attributedString.yy_lineSpacing = 6;
        attributedString.yy_color = [UIColor colorWithHexString:@"EC8C00"];
        _topTipsLab.attributedText = attributedString;
     }
    return _topTipsLab;
}
- (UILabel *)selecttribeTitleLab {
    if (!_selecttribeTitleLab) {
        _selecttribeTitleLab = [[UILabel alloc] init];
        _selecttribeTitleLab.textColor = [UIColor textBlackColor];
        _selecttribeTitleLab.font = [UIFont middleFont];
        _selecttribeTitleLab.text = @"请您选择一个养猪部落，给小猪落个户口吧！";
    }
    return _selecttribeTitleLab;
}
- (UILabel *) provinceLab{
    if (!_provinceLab) {
        _provinceLab = [[UILabel alloc] init];
        _provinceLab.textColor = AreaGrayColor;
        _provinceLab.font = [UIFont middleFont];
        _provinceLab.text = @"选择省份";
    }
    return _provinceLab;
}
- (UILabel *)defaultProvinceLab {
    if (!_defaultProvinceLab) {
        _defaultProvinceLab = [[UILabel alloc] init];
        _defaultProvinceLab.textColor = [UIColor primaryColor];
        _defaultProvinceLab.font = [UIFont middleFont];
    }
    return _defaultProvinceLab;
}
- (UIButton *)selectProvinceBtn {
    if (!_selectProvinceBtn) {
        _selectProvinceBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_selectProvinceBtn setImage:[UIImage imageNamed:@"login_pulldown"] forState:UIControlStateNormal];
        [_selectProvinceBtn setImage:[UIImage imageNamed:@"login_pulldown_selected"] forState:UIControlStateSelected];
//        NSInteger widehEdge =  (_selectDistrictBtn.intrinsicContentSize.width - 26) / 2;
        [_selectProvinceBtn setImageEdgeInsets:UIEdgeInsetsMake(0, 87, 0, -87)];
    }
    return _selectProvinceBtn;
}
- (UIView *)provinceLine {
    if (!_provinceLine) {
        _provinceLine = [[UIView alloc] init];
        _provinceLine.backgroundColor = [UIColor colorWithHexString:@"#000000" alpha:0.08];
    }
    return _provinceLine;
}
- (UILabel *)cityLab{
    if (!_cityLab) {
        _cityLab = [[UILabel alloc] init];
        _cityLab.textColor = AreaGrayColor;
        _cityLab.font = [UIFont middleFont];
        _cityLab.text = @"选择城市";
    }
    return _cityLab;
}
- (UILabel *)defaultCityLab {
    if (!_defaultCityLab) {
        _defaultCityLab = [[UILabel alloc] init];
        _defaultCityLab.textColor = [UIColor primaryColor];
        _defaultCityLab.font = [UIFont middleFont];
    }
    return _defaultCityLab;
}
- (UIButton *)selectCityBtn {
    if (!_selectCityBtn) {
        _selectCityBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_selectCityBtn setImage:[UIImage imageNamed:@"login_pulldown"] forState:UIControlStateNormal];
        [_selectCityBtn setImage:[UIImage imageNamed:@"login_pulldown_selected"] forState:UIControlStateSelected];
        [_selectCityBtn setImageEdgeInsets:UIEdgeInsetsMake(0, 87, 0, -87)];
    }
    return _selectCityBtn;
}
- (UIView *)cityLine {
    if (!_cityLine) {
        _cityLine = [[UIView alloc] init];
        _cityLine.backgroundColor = [UIColor colorWithHexString:@"#000000" alpha:0.08];
    }
    return _cityLine;
}
- (UILabel *)districtLab{
    if (!_districtLab) {
        _districtLab = [[UILabel alloc] init];
        _districtLab.textColor = AreaGrayColor;
        _districtLab.font = [UIFont middleFont];
        _districtLab.text = @"选择区县";
    }
    return _districtLab;
}
- (UILabel *)defaultDistrictLab {
    if (!_defaultDistrictLab) {
        _defaultDistrictLab = [[UILabel alloc] init];
        _defaultDistrictLab.textColor = [UIColor primaryColor];
        _defaultDistrictLab.font = [UIFont middleFont];
    }
    return _defaultDistrictLab;
}
- (UIButton *)selectDistrictBtn {
    if (!_selectDistrictBtn) {
        _selectDistrictBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_selectDistrictBtn setImage:[UIImage imageNamed:@"login_pulldown"] forState:UIControlStateNormal];
        [_selectDistrictBtn setImage:[UIImage imageNamed:@"login_pulldown_selected"] forState:UIControlStateSelected];
        [_selectDistrictBtn setImageEdgeInsets:UIEdgeInsetsMake(0, 87, 0, -87)];
    }
    return _selectDistrictBtn;
}
- (UIView *)districtLine {
    if (!_districtLine) {
        _districtLine = [[UIView alloc] init];
        _districtLine.backgroundColor = [UIColor colorWithHexString:@"#000000" alpha:0.08];
    }
    return _districtLine;
}
- (UILabel *)tribeLab{
    if (!_tribeLab) {
        _tribeLab = [[UILabel alloc] init];
        _tribeLab.textColor = AreaGrayColor;
        _tribeLab.font = [UIFont middleFont];
        _tribeLab.text = @"选择部落";
    }
    return _tribeLab;
}
- (UILabel *)defaulTribeLab{
    if (!_defaulTribeLab) {
        _defaulTribeLab = [[UILabel alloc] init];
        _defaulTribeLab.textColor = [UIColor primaryColor];
        _defaulTribeLab.font = [UIFont middleFont];
    }
    return _defaulTribeLab;
}
- (UIButton *)selecttribeBtn {
    if (!_selecttribeBtn) {
        _selecttribeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_selecttribeBtn setImage:[UIImage imageNamed:@"login_pulldown"] forState:UIControlStateNormal];
        [_selecttribeBtn setImage:[UIImage imageNamed:@"login_pulldown_selected"] forState:UIControlStateSelected];
        [_selecttribeBtn setImageEdgeInsets:UIEdgeInsetsMake(0, 87, 0, -87)];

    }
    return _selecttribeBtn;
}
- (UIView *)tribeLine {
    if (!_tribeLine) {
        _tribeLine = [[UIView alloc] init];
        _tribeLine.backgroundColor = [UIColor colorWithHexString:@"#000000" alpha:0.08];
    }
    return _tribeLine;
}
- (UIButton *)confirmBtn {
    if (!_confirmBtn) {
        _confirmBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_confirmBtn setTitle:@"确定" forState:UIControlStateNormal];
        [_confirmBtn setBackgroundImage:[UIImage imageNamed:@"login_loginbtn_default"] forState:UIControlStateNormal];
    }
    return _confirmBtn;
}
- (UILabel *)bottomTips {
    if (!_bottomTips) {
        _bottomTips = [[UILabel alloc] init];
        _bottomTips.textColor = [UIColor tipsGrayColor];
        _bottomTips.font = [UIFont smallFont];
        _bottomTips.numberOfLines = 0;
    }
    return _bottomTips;
}
- (NSMutableArray *)provinceArr {
    if (!_provinceArr) {
        _provinceArr = [[NSMutableArray alloc] init];
    }
    return _provinceArr;
}
- (NSMutableArray *)cityArr {
    if (!_cityArr) {
        _cityArr = [[NSMutableArray alloc] init];
    }
    return _cityArr;
}
- (NSMutableArray *)districtArr {
    if (!_districtArr) {
        _districtArr = [[NSMutableArray alloc] init];
    }
    return _districtArr;
}
- (NSMutableArray *)tribeArr {
    if (!_tribeArr) {
        _tribeArr = [[NSMutableArray alloc] init];
    }
    return _tribeArr;
}
- (AreaDropDownListView *)areaDropDownView {
    if (!_areaDropDownView) {
        _areaDropDownView = [AreaDropDownListView sharedInstance];
    }
    return _areaDropDownView;
}

@end
